package com.situ.day04;

import java.util.Scanner;

import org.junit.Test;

public class ArrayHomeWork {
	public static void main(String[] args) {

	}

	@Test
	public void test00() {
		int[] scores = { 0, 0, 1, 2, 3, 5, 4, 5, 2, 8, 7, 6, 9, 5, 4, 8, 3, 1, 0, 2, 4, 8, 7, 9, 5, 2, 1, 2, 3, 9 };
		int count = 0;
		int[] array = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < scores.length; j++) {
				if (scores[j] == array[i]) {
					count++;
				}
			}
			System.out.println(i + "出现" + count + "次");
			count = 0;
		}
	}

	@Test
	public void test11() {
		int[] scores = { 0, 0, 1, 2, 3, 5, 4, 5, 2, 8, 7, 6, 9, 5, 4, 8, 3, 1, 0, 2, 4, 8, 7, 9, 5, 2, 1, 2, 3, 9 };
		int count = 0;
		int[] array = new int[30];
		for (int i = 0; i < scores.length; i++) {
			int j = 0;
			for (; j < count; j++) {
				if (scores[i] == array[j]) {
					break;
				}
			}
			if (j == count) {
				array[count++] = scores[i];
			}

		}
		for (int i = 0; i < count; i++) {
			System.out.print(array[i] + " ");
		}
		System.out.println();
	}

	@Test
	public void test22() {
		int count1 = 0;
		int count2 = 0;
		int[] scores = { 0, 0, 1, 2, 3, 5, 4, 5, 2, 8, 7, 6, 9, 5, 4, 8, 3, 1, 0, 2, 4, 8, 7, 9, 5, 2, 1, 2, 3, 9 };
		for (int i = 0; i < scores.length; i++) {
			if (scores[i] % 2 != 0) {
				count1++;
			} else if (scores[i] % 2 == 0) {
				count2++;
			}
		}
		System.out.println("奇数的个数" + count1 + "偶数的个数" + count2);
	}

	@Test
	public void test33() {
		Scanner scanner = new Scanner(System.in);
		int[] scores = new int[10];
		System.out.println("输入十名学生的成绩");
		for (int i = 0; i < scores.length; i++) {
			scores[i] = scanner.nextInt();
		}
		int sum = 0;
		for (int i = 0; i < scores.length; i++) {
			sum += scores[i];
		}

		System.out.println(sum);
		System.out.println(sum / scores.length);

	}

	@Test
	public void test44() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入一个五位数：");
		int a = scanner.nextInt();
		int[] array = new int[5];
		array[0] = a / 10000;
		array[1] = (a % 10000) / 1000;
		array[3] = (a % 100) / 10;
		array[4] = (a % 10);
		if (array[0] == array[4] && array[1] == array[3]) {
			System.out.println(a + "是回文数");
		} else {
			System.out.println(a + "不是回文数");
		}

	}

	@Test
	public void test55() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入一串字符:");
		String str = scanner.nextLine();
		int spaceCount = 0;
		int numberCount = 0;
		int englishCount = 0;
		for (int i = 0; i < str.length(); i++) {
			if (str.charAt(i) == ' ') {
				spaceCount++;
			} else if (str.charAt(i) >= 48 && str.charAt(i) <= 57) {
				numberCount++;
			} else if ((str.charAt(i) >= 65 && str.charAt(i) <= 90) || (str.charAt(i) >= 97 && str.charAt(i) <= 122)) {
				englishCount++;
			}
		}
		System.out.println("空格：" + spaceCount + "数字：" + numberCount + "字母：" + englishCount);
	}

}
